package com.quanquan.store.repository;

import com.quanquan.store.entity.Admin;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @ClassName:AdminRepository
 * @Description:TODO
 * @Author:xiongjunbao
 * @Date:2019/3/29 16:04
 * @Version 1.0
 */
public interface AdminRepository extends JpaRepository<Admin,String> , JpaSpecificationExecutor<Admin> {

    @Query(value = "select * from oo_admin where account = ?1 and password =?2 and status = 0",nativeQuery = true)
    Admin findByAccountAndPassword(String account, String password);

    @Query(value = "select * from oo_admin where account = ?1 and status = 0",nativeQuery = true)
    Admin findByAccount(String account);

    @Query(value = "select * from oo_admin where id = ?1 and status = 0",nativeQuery = true)
    Admin findByAdminId(String id);

    @Query(value = "select * from oo_admin where status = 0 limit ?1,?2",nativeQuery = true)
    List<Admin> findAllAdmin(Integer count, Integer size);

    @Query(value = "select * from oo_admin where store_id = ?1 and status = 0",nativeQuery = true)
    List<Admin> findByStoreIdAndLevel(String storeId);

}
